const express = require('express')
const morgan = require('morgan')
const cors = require('cors')
const router = require('./router')
const errorHandler = require("./middleware/error-handler")
const PORT = process.env.PORT || 3000;
const app = express()

app.use(express.json())
app.use(express.urlencoded())
app.use(morgan("dev"))
app.use(cors())

app.use('/api',router)
app.use(errorHandler())
app.listen(PORT,() => {
    console.log('Server is running at ' + PORT);
})